
package com.jf.cloud.biz.controller.app;

import com.jf.cloud.biz.dto.NotifyTemplateRemindDTO;
import com.jf.cloud.biz.model.NotifyTemplateRemind;
import com.jf.cloud.biz.service.NotifyTemplateRemindService;
import com.jf.cloud.common.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 消息提醒设置
 *
 * @author zz
 * @date 2022-10-24 13:48:38
 */
@RestController("appNotifyTemplateRemindController")
@RequestMapping("/notify_template_remind")
@Tag(name = "消息提醒设置")
public class NotifyTemplateRemindController {

    @Autowired
    private NotifyTemplateRemindService notifyTemplateRemindService;

    @Autowired
    private MapperFacade mapperFacade;


    @GetMapping
    @Operation(summary = "获取消息提醒设置" , description = "根据notifyTemplateRemindId获取消息提醒设置")
    public ServerResponseEntity<NotifyTemplateRemind> getByNotifyTemplateRemindId(@RequestParam Long notifyTemplateRemindId) {
        return ServerResponseEntity.success(notifyTemplateRemindService.getByNotifyTemplateRemindId(notifyTemplateRemindId));
    }

    @PostMapping
    @Operation(summary = "保存消息提醒设置" , description = "保存消息提醒设置")
    public ServerResponseEntity<Void> save(@Valid @RequestBody NotifyTemplateRemindDTO notifyTemplateRemindDTO) {
        NotifyTemplateRemind notifyTemplateRemind = mapperFacade.map(notifyTemplateRemindDTO, NotifyTemplateRemind.class);
        notifyTemplateRemindService.save(notifyTemplateRemind);
        return ServerResponseEntity.success();
    }

    @PutMapping
    @Operation(summary = "更新消息提醒设置" , description = "更新消息提醒设置")
    public ServerResponseEntity<Void> update(@Valid @RequestBody NotifyTemplateRemindDTO notifyTemplateRemindDTO) {
        NotifyTemplateRemind notifyTemplateRemind = mapperFacade.map(notifyTemplateRemindDTO, NotifyTemplateRemind.class);
        notifyTemplateRemindService.update(notifyTemplateRemind);
        return ServerResponseEntity.success();
    }

    @DeleteMapping
    @Operation(summary = "删除消息提醒设置" , description = "根据消息提醒设置id删除消息提醒设置")
    public ServerResponseEntity<Void> delete(@RequestParam Long notifyTemplateRemindId) {
        notifyTemplateRemindService.deleteById(notifyTemplateRemindId);
        return ServerResponseEntity.success();
    }
}
